<!DOCTYPE html>
<html>
<head>
    <!--purchase_drup_detail-->
	<meta charset="utf-8">
	<title>文章列表--layui后台管理模板 2.0</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="resources/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="resources/css/public.css" media="all" />
</head>
<body class="childrenBody">
<!--展示采购单-->
<div class="layui-collapse" id="showPurchase">
	<blockquote class="layui-elem-quote quoteBox">
        <form class="layui-form" id="purchaseShow" lay-filter="purchaseShow">
    	    <div class="layui-form-item layui-row">
    	        <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">医院编号</label>
                	<div class="layui-input-block">
                	    <input type="hidden" name="id">
                		<input type="text" name="hospitalId" id="hospitalId" class="layui-input searchVal" readonly />
                	</div>
                </div>
                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">医院名称</label>
                	<div class="layui-input-block">
                		<input type="text" name="hospitalName" id="hospitalName" class="layui-input searchVal" readonly />
                	</div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">采购单编号</label>
                	<div class="layui-input-block">
                	    <input name="purchaseNum" class="layui-input searchVal" id="purchaseNum" readonly />
                	</div>
                </div>
                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">采购单名称</label>
                	<div class="layui-input-block">
                	    <input name="purchaseName" readonly class="layui-input searchVal" lay-verify="required" id="purchaseName" placeholder="请输入采购单名称" >
                	</div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">采购时间</label>
                	<div class="layui-input-block">
                		<input type="text" name="createTime" class="layui-input createTime" lay-verify="required" readonly placeholder="yyyy-MM-dd">
                	</div>
                </div>
                <div class="layui-inline layui-col-md6">
                	<label class="layui-form-label">结束时间</label>
                	<div class="layui-input-block">
                    	<input type="text" class="layui-input" name="overTime" lay-verify="required" readonly id="overTime" placeholder="yyyy-MM-dd">
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">联系人</label>
                	<div class="layui-input-block">
                		<input type="text" name="linkman" class="layui-input searchVal" placeholder="请输入联系人" />
                	</div>
                </div>
                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">联系电话</label>
                	<div class="layui-input-block">
                		<input type="text" name="linkphone" lay-verify="phone" class="layui-input searchVal" placeholder="请输入联系电话" />
                	</div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">采购单状态</label>
                	<div class="layui-input-block">
                		<select name="purchaseState" id="purchaseState" lay-filter="purchaseState">
                            <option>请选择采购单状态：</option>
                        </select>
                        <div class="mydiv" title="不可修改" style="position:absolute;width: 100%;height: 100%;left: 0px;top: 0px;background: #fff;opacity: 0;filter:alpha(opacity=0)"></div>
                	</div>
                </div>
                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">提交时间</label>
                	<div class="layui-input-block">
                		<input type="text" name="submitTime" readonly class="layui-input searchVal" placeholder="yyyy-MM-dd" />
                	</div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-block ">
                    <label class="layui-form-label">备注</label>
                	<div class="layui-input-block">
                		<input type="text" name="remark" class="layui-input searchVal" placeholder="请输入备注" />
                	</div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">审核人</label>
                	<div class="layui-input-block">
                		<input type="text" name="auditor" readonly class="layui-input searchVal"/>
                	</div>
                </div>
                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">审核时间</label>
                	<div class="layui-input-block">
                		<input type="text" name="auditorTime" readonly class="layui-input searchVal" placeholder="yyyy-MM-dd">
                	</div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">建单时间</label>
                	<div class="layui-input-block">
                		<input type="text" name="createTime" readonly class="layui-input searchVal createTime" placeholder="yyyy-MM-dd"/>
                	</div>
                </div>
                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">审核意见</label>
                	<div class="layui-input-block">
                		<input type="text" name="auditorAdvice" readonly class="layui-input searchVal" placeholder="请输入审核意见" />
                	</div>
                </div>
            </div>
            <div class="layui-form-item layui-center">
                <div class="layui-input-block">
                  <button type="submit" class="layui-btn" lay-submit="" lay-filter="save">保存采购单</button>
                  <button type="submit" class="layui-btn" lay-submit="" lay-filter="submit">提交采购单</button>
                </div>
            </div>
    	</form>
	</blockquote>
</div>
<!--采购目录模糊查询-->
<div class="layui-collapse layui-row" id="search">
    <blockquote style="margin-right: 10%" class="layui-elem-quote quoteBox layui-col-lg-offset1">
        <form class="layui-form" id="searchTable" lay-filter="searchTable">
    	    <div class="layui-form-item layui-row">
    	        <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">药品流水号</label>
                	<div class="layui-input-block">
                		<input type="text" name="serialNumber" id="serialNumber" class="layui-input searchVal" />
                	</div>
                </div>
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">通用名</label>
                	<div class="layui-input-block">
                		<input type="text" name="commonName" id="commonName" class="layui-input searchVal" />
                	</div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">剂型</label>
                	<div class="layui-input-block">
                	    <input name="dosageForm" class="layui-input searchVal" id="dosageForm" />
                	</div>
                </div>
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">规格</label>
                	<div class="layui-input-block">
                	    <input name="size" class="layui-input searchVal" id="size" >
                	</div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">单位</label>
                	<div class="layui-input-block">
                		<input type="text" name="unit" class="layui-input createTime">
                	</div>
                </div>
                <div class="layui-inline layui-col-md5">
                	<label class="layui-form-label">转换系数</label>
                	<div class="layui-input-block">
                    	<input type="text" class="layui-input" name="factor" id="factor">
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">生产企业</label>
                	<div class="layui-input-block">
                		<input type="text" name="productionName" class="layui-input searchVal"/>
                	</div>
                </div>
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">商品名</label>
                	<div class="layui-input-block">
                		<input type="text" name="commodityName" class="layui-input searchVal"/>
                	</div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">质量层次</label>
                	<div class="layui-input-block">
                		<select name="quality" id="quality" lay-filter="quality">
                            <option>请选择质量层次：</option>
                        </select>
                	</div>
                </div>
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">药品类别</label>
                	<div class="layui-input-block">
                		<select name="drugCategory" id="drugCategory" lay-filter="drugCategory">
                            <option>请选择药品类别：</option>
                        </select>
                	</div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">供应商</label>
                	<div class="layui-input-block">
                		<select name="providerId" id="provider" lay-filter="provider">
                            <option>请选择供应商：</option>
                        </select>
                	</div>
                </div>
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">采购状态</label>
                	<div class="layui-input-block">
                		<select name="purchaseState" id="purchaseSta" lay-filter="purchaseSta">
                            <option>请选择采购状态：</option>
                        </select>
                	</div>
                </div>
            </div>
            <div class="layui-form-item layui-center">
                <div class="layui-input-block">
                   <button type="submit" class="layui-btn" lay-submit="" lay-filter="search">查询</button>
                   <button type="button" class="layui-btn" lay-submit="" lay-filter="output">导出</button>
                </div>
            </div>
    	</form>
    </blockquote>
</div>
<!--数据表格-->
<div>
    <table class="layui-hide" id="drugTable" lay-filter="drugTable"></table>
    <div id="toolBars" style="display: none">
        <button type="button" lay-event="add" class="layui-btn layui-btn-sm"><span class="layui-icon layui-icon-add-1"></span>添加</button>
        <button type="button" lay-event="delete" class="layui-btn layui-btn-sm"><span class="layui-icon layui-icon-add-1"></span>删除</button>
        <button type="button" lay-event="save" class="layui-btn layui-btn-sm"><span class="layui-icon layui-icon-add-1"></span>保存采购量</button>
        <button type="button" lay-event="delay" class="layui-btn layui-btn-sm"><span class="layui-icon layui-icon-add-1"></span>到期未送货</button>
    </div>
    <div id="rowBars" style="display: none">
        <button type="button" lay-event="show" class="layui-btn layui-btn-sm layui-btn-warm"><span class="layui-icon layui-icon-search"></span>查看</button>
        <button type="button" lay-event="update" class="layui-btn layui-btn-sm layui-bg-green"><span class="layui-icon layui-icon-edit"></span>修改供货企业</button>
    </div>
</div>
<!--选泽供货企业-->
<div>
    <table style="display: none" id="selectProvider" lay-filter="selectProvider"></table>
    <div id="row" style="display: none">
        <button type="button" lay-event="detail" class="layui-btn layui-btn-sm layui-btn-warm"><span class="layui-icon layui-icon-search"></span>详情</button>
    </div>
</div>
<!--展示数据-->
<div style="display: none" id="showData" lay-filter="showData">
    <h2 style="margin-left: 10px">采购详情</h2>
    <form class="layui-form" id="showDataForm" lay-filter="showDataForm">
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">中标价</label>
            	<div class="layui-input-inline">
            		<input type="text" name="winPrice" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">采购状态</label>
            	<div class="layui-input-inline">
            		<input type="text" name="purchaseState" id="layerPurchaseState" readonly class="layui-input searchVal" />
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">交易价</label>
            	<div class="layui-input-inline">
            		<input type="text" name="trading" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">采购量</label>
            	<div class="layui-input-inline">
            		<input type="text" name="purchaseAmount" readonly class="layui-input searchVal" placeholder="yyyy-MM-dd">
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">采购总金额</label>
            	<div class="layui-input-inline">
            		<input type="text" name="purchasePrice" readonly class="layui-input searchVal" />
            	</div>
            </div>
        </div>
	</form>
	<h2 style="margin-left: 10px">药品信息</h2>
	<form class="layui-form" id="showDataDrugForm" lay-filter="showDataDrugForm">
        <div class="layui-form-item">
	        <div class="layui-inline ">
                <label class="layui-form-label">药品名</label>
            	<div class="layui-input-inline">
            	    <input type="hidden" name="id">
            		<input type="text" name="commodityName" class="layui-input searchVal" readonly />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">药品流水号</label>
            	<div class="layui-input-inline">
            		<input type="text" name="serialNumber" class="layui-input searchVal" readonly />
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">药品通用名</label>
            	<div class="layui-input-inline">
            	    <input name="commonName" class="layui-input searchVal" readonly />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">批准文号</label>
            	<div class="layui-input-inline">
            		<input type="text" name="approvalNumber" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">剂型</label>
            	<div class="layui-input-inline">
            		<input type="text" name="dosageForm" class="layui-input" readonly>
            	</div>
            </div>
            <div class="layui-inline ">
            	<label class="layui-form-label">规格</label>
            	<div class="layui-input-inline">
                	<input type="text" class="layui-input" name="size" readonly>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">单位</label>
            	<div class="layui-input-inline">
            		<input type="text" name="unit" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">转换系数</label>
            	<div class="layui-input-inline">
            		<input type="text" name="factor" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">质量层次</label>
            	<div class="layui-input-inline">
            	    <input type="text" name="quality" id="layerQuality" readonly class="layui-input searchVal" placeholder="yyyy-MM-dd" />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">生产企业</label>
            	<div class="layui-input-inline">
            		<input type="text" name="productionName" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">药品类别</label>
            	<div class="layui-input-inline">
            	    <input type="text" name="drugCategory" id="layerDrugCategory" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">通用名拼音</label>
            	<div class="layui-input-inline">
            		<input type="text" name="commodityPinyin" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">批准文号有效期</label>
            	<div class="layui-input-inline">
            	    <input type="text" name="approvalDate" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">是否是进口药</label>
            	<div class="layui-input-inline">
            		<input type="text" name="isImport" id="layerIsImport" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">包装材质</label>
            	<div class="layui-input-inline">
            	    <input type="text" name="packages" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">包装单位</label>
            	<div class="layui-input-inline">
            		<input type="text" name="packageUnit" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">最新零售价</label>
            	<div class="layui-input-inline">
            	    <input type="text" name="newPrice" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">零售价出处</label>
            	<div class="layui-input-inline">
            		<input type="text" name="priceSource" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">质量层次说明</label>
            	<div class="layui-input-inline">
            	    <input type="text" name="qualityDescription" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">有无质检报告</label>
            	<div class="layui-input-inline">
            		<input type="text" name="haveReport" id="layerHaveReport" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">质检报告编号</label>
            	<div class="layui-input-inline">
            	    <input type="text" name="reportNum" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">质检报告有效期</label>
            	<div class="layui-input-inline">
            		<input type="text" name="reportDate" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">产品说明</label>
            	<div class="layui-input-inline">
            	    <input type="text" name="productionDescription" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">药品状态</label>
            	<div class="layui-input-inline">
            		<input type="text" name="transaction" id="layerTransaction" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">质量层次说明</label>
            	<div class="layui-input-inline">
            	    <input type="text" name="qualityDescription" readonly class="layui-input searchVal"/>
            	</div>
            </div>
        </div>
    </form>
    <h2 style="margin-left: 10px">供应商详情</h2>
    <form class="layui-form" id="showDataProviderForm" lay-filter="showDataProviderForm">
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">企业名称</label>
            	<div class="layui-input-inline">
            		<input type="text" name="providerName" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">企业类别</label>
            	<div class="layui-input-inline">
            		<input type="text" name="providerCategory" readonly class="layui-input searchVal" />
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">许可证</label>
            	<div class="layui-input-inline">
            		<input type="text" name="licence" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">许可证到期时间</label>
            	<div class="layui-input-inline">
            		<input type="text" name="licenceDeadline" readonly class="layui-input searchVal">
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">企业联系人</label>
            	<div class="layui-input-inline">
            		<input type="text" name="providerLinkman" readonly class="layui-input searchVal" />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">企业联系电话</label>
            	<div class="layui-input-inline">
            		<input type="text" name="providerPhone" readonly class="layui-input searchVal">
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">营业范围</label>
            	<div class="layui-input-inline">
            		<input type="text" name="businessScope" readonly class="layui-input searchVal" />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">注册地址</label>
            	<div class="layui-input-inline">
            		<input type="text" name="registeredAddress" readonly class="layui-input searchVal">
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">联系地址</label>
            	<div class="layui-input-inline">
            		<input type="text" name="contactAddress" readonly class="layui-input searchVal" />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">邮政编码</label>
            	<div class="layui-input-inline">
            		<input type="text" name="postalCode" readonly class="layui-input searchVal">
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">总资产</label>
            	<div class="layui-input-inline">
            		<input type="text" name="totalAssets" readonly class="layui-input searchVal" />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">企业传真</label>
            	<div class="layui-input-inline">
            		<input type="text" name="providerFax" readonly class="layui-input searchVal">
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">法人代表</label>
            	<div class="layui-input-inline">
            		<input type="text" name="corporateRepresentative" readonly class="layui-input searchVal" />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">法人身份证</label>
            	<div class="layui-input-inline">
            		<input type="text" name="corporataNumber" readonly class="layui-input searchVal">
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">企业注册资金</label>
            	<div class="layui-input-inline">
            		<input type="text" name="registeredCapital" readonly class="layui-input searchVal" />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">上年度销售金额</label>
            	<div class="layui-input-inline">
            		<input type="text" name="annualSalesAmount" readonly class="layui-input searchVal">
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">电子信箱</label>
            	<div class="layui-input-inline">
            		<input type="text" name="email" readonly class="layui-input searchVal" />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">网址</label>
            	<div class="layui-input-inline">
            		<input type="text" name="url" readonly class="layui-input searchVal">
            	</div>
            </div>
        </div>
	</form>
</div>
<!--展示供货企业信息-->
<div style="display: none" id="showProvider" lay-filter="showProvider">
    <form class="layui-form" id="showProviderForm" lay-filter="showProviderForm">
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">企业名称</label>
            	<div class="layui-input-inline">
            		<input type="text" name="providerName" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">企业类别</label>
            	<div class="layui-input-inline">
            		<input type="text" name="providerCategory" readonly class="layui-input searchVal" />
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline ">
                <label class="layui-form-label">许可证</label>
            	<div class="layui-input-inline">
            		<input type="text" name="licence" readonly class="layui-input searchVal"/>
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">许可证到期时间</label>
            	<div class="layui-input-inline">
            		<input type="text" name="licenceDeadline" readonly class="layui-input searchVal">
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">企业联系人</label>
            	<div class="layui-input-inline">
            		<input type="text" name="providerLinkman" readonly class="layui-input searchVal" />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">企业联系电话</label>
            	<div class="layui-input-inline">
            		<input type="text" name="providerPhone" readonly class="layui-input searchVal">
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">营业范围</label>
            	<div class="layui-input-inline">
            		<input type="text" name="businessScope" readonly class="layui-input searchVal" />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">注册地址</label>
            	<div class="layui-input-inline">
            		<input type="text" name="registeredAddress" readonly class="layui-input searchVal">
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">联系地址</label>
            	<div class="layui-input-inline">
            		<input type="text" name="contactAddress" readonly class="layui-input searchVal" />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">邮政编码</label>
            	<div class="layui-input-inline">
            		<input type="text" name="postalCode" readonly class="layui-input searchVal">
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">总资产</label>
            	<div class="layui-input-inline">
            		<input type="text" name="totalAssets" readonly class="layui-input searchVal" />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">企业传真</label>
            	<div class="layui-input-inline">
            		<input type="text" name="providerFax" readonly class="layui-input searchVal">
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">法人代表</label>
            	<div class="layui-input-inline">
            		<input type="text" name="corporateRepresentative" readonly class="layui-input searchVal" />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">法人身份证</label>
            	<div class="layui-input-inline">
            		<input type="text" name="corporataNumber" readonly class="layui-input searchVal">
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">企业注册资金</label>
            	<div class="layui-input-inline">
            		<input type="text" name="registeredCapital" readonly class="layui-input searchVal" />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">上年度销售金额</label>
            	<div class="layui-input-inline">
            		<input type="text" name="annualSalesAmount" readonly class="layui-input searchVal">
            	</div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">电子信箱</label>
            	<div class="layui-input-inline">
            		<input type="text" name="email" readonly class="layui-input searchVal" />
            	</div>
            </div>
            <div class="layui-inline ">
                <label class="layui-form-label">网址</label>
            	<div class="layui-input-inline">
            		<input type="text" name="url" readonly class="layui-input searchVal">
            	</div>
            </div>
        </div>
	</form>
</div>
<!--展示有效的供货企业-->
<script type="text/javascript" src="resources/layui/layui.js"></script>
<script>
    layui.use(['form','jquery','layer','laydate','element','table'],function() {
        var form = layui.form;
        var laydate = layui.laydate;
        var layer = layui.layer;
        var $ = layui.jquery;
        var table = layui.table;
        //填充采购单,采购单id
        var id = location.href.split("?id=")[1];
        if(id.indexOf("&")!=-1){
            id = id.split("&")[0];
        }
        //获取医院id
        var hospitalId;
        //获取采购单状态
        var purchaseState;
        //获得采购单数据
        $.ajax({
            url:"/purchase/getPurchaseById",
            data:{id:id},
            async:false,
            type:"post",
            success:function(data) {
                form.val("purchaseShow",data);
                hospitalId = data.hospitalId;
                purchaseState = data.purchaseState;
            }
        });
        //加载下拉框
        select($("#purchaseState"),"/getPurchaseState",purchaseState);
        select($("#purchaseSta"),"/getPurchaseSta");
        select($("#quality"),"/getQuality");
        selectDrugCategory($("#drugCategory"),"/getDrugCategory");
        selectProvider($("#provider"),"/provider/getProvider");
        //添加药品信息时，需要传递
        var drugMessageIds = new Array();
        //存储表中数据
        var tableData = new Array();
        var tableIns = table.render({
            elem:"#drugTable",
            url:"/purchase/getAvailableDrug",
            where:{purchaseId:id},
            id:"drugTableId",
            page:true,
            totalRow: true,
            toolbar:"#toolBars",
            cols:[
                [
                    {field:'id', title:'ID',  fixed: 'left', unresize: true,width:'80' ,sort: true,align:'center', totalRowText: '合计'}
                    ,{type:'checkbox',fixed:'center'}
                    ,{field:'drugMessage.serialNumber', title:'流水号',align:'center',width:'180',templet:function(res) {
                        return res.drugMessage==undefined?"":res.drugMessage.serialNumber;
                    }}
                    ,{field:'drugMessage.commonName',sort:true ,title:'通用名',align:'center',width:'180',templet:function (res) {
                        return res.drugMessage==undefined?"":res.drugMessage.commonName;
                     }}
                    ,{field:'drugMessage.commodityName', title:'商品名',align:'center',width:'180',templet:function(res) {
                        return res.drugMessage==undefined?"":res.drugMessage.commodityName;
                    }}
                    ,{field:'drugMessage.dosageForm', title:'剂型',align:'center',width:'180',templet:function(res) {
                        return res.drugMessage==undefined?"":res.drugMessage.dosageForm;
                    }}
                    ,{field:'drugMessage.size', title:'规格',align:'center',width:'180',templet:function(res) {
                        return res.drugMessage==undefined?"":res.drugMessage.size;
                    }}
                    ,{field:'drugMessage.unit', title:'单位',align:'center',width:'180',templet:function(res) {
                        return res.drugMessage==undefined?"":res.drugMessage.unit;
                    }}
                    ,{field:'drugMessage.factor', title:'转换系数',align:'center',width:'180',templet:function (res) {
                        return res.drugMessage==undefined?"":res.drugMessage.factor;
                     }}
                    ,{field:'drugMessage.quality', title:'质量层次',align:'center',width:'180',templet:function(res) {
                        return res.drugMessage==undefined?"":res.drugMessage.quality==1?"国家一类新药":
                        res.drugMessage.quality==2?"国家科学进步奖":
                        res.drugMessage.quality==3?"专利":
                        res.drugMessage.quality==4?"原研":
                        res.drugMessage.quality==5?"单独定价":
                        res.drugMessage.quality==6?"优质优价":
                        res.drugMessage.quality==7?"GMP":"";
                    }}
                    ,{field:'drugMessage.productionName', title:'生产企业',align:'center',width:'180',templet:function(res) {
                        return res.drugMessage==undefined?"":res.drugMessage.productionName;
                    }}
                    ,{field:'winPrice', title:'中标价',align:'center',width:'180'}
                    ,{field:'trading', title:'交易价',align:'center',width:'180',edit:true}
                    ,{field:'purchaseAmount', title:'采购量',align:'center',width:'180',edit:true,totalRow: true}
                    ,{field:'purchasePrice', title:'采购总金额',align:'center',width:'180',totalRow: true}
                    ,{field:'provider.providerName', title:'供货企业',align:'center',width:'180',templet:function(res) {
                        return res.provider==undefined?"":res.provider.providerName
                    }}
                    ,{field:'purchaseState', title:'采购状态',align:'center',width:'180',templet:function (d) {
                        return d.purchaseState==1?"未确认送货":
                        d.purchaseState==2?"已发货":
                        d.purchaseState==3?"已入库":
                        d.purchaseState==4?"无法供货":
                        d.purchaseState==5?"到期未供货":"";
                     }}
                    ,{fixed: 'right', title:'操作', toolbar: '#rowBars',width:260}
                ]
            ],
            done:function(res,curr,count) {
                drugMessageIds = [];
                tableData = [];
                $.each(res.data,function(index,item) {
                    drugMessageIds.push(item.drugMessageId);
                    tableData.push(item);
                });
            }
        });


        //监听头部工具栏事件
        table.on('toolbar(drugTable)',function(obj) {
            switch (obj.event) {
                case 'add':
                    openAdd();
                    break;
                case 'delete':
                    openDelete();
                    break;
                case 'save':
                    openSave();
                    break;
            }
        });
        //监听行工具栏事件
        table.on('tool(drugTable)',function(obj) {
            switch (obj.event) {
                case 'show':
                    openShow(obj.data);
                    break;
                case 'update':
                    changeProvider(obj.data);
            }
        });
        //监听选择供应商行工具栏事件
        table.on('tool(selectProvider)',function(obj) {
            switch (obj.event) {
                case 'detail':
                    showProvider(obj.data);
                    break;
            }
        });
        //表单提交查询
        form.on("submit(search)",function(data) {
            tableIns.reload({
                where:data.field
            });
            return false;
        });
        //导出
        form.on("submit(output)",function() {
            //选中导出
            var checkStatus = table.checkStatus('drugTableId'); //idTest 即为基础参数 id 对应的值
            if(checkStatus.data.length>0){
                table.exportFile(tableIns.config.id,checkStatus.data,'xls');
            }else {
                layer.msg("请先勾选数据");
            }
            return false;
        });
        //保存采购单
        form.on("submit(save)",function(data){

            //修改最近修改时间
            var date = new Date();
            data.field.recentTime = dateToString(date);
            $.post("/purchase/update",data.field,function(res) {
                layer.msg(res.msg);
                setTimeout(function() {
                    window.location.href = '/toPurchase';
                },1000);

            });
            return false;
        })
        //提交采购单
        form.on("submit(submit)",function(){
            //未提交或未通过
            if(purchaseState!=1&&purchaseState!=4){
                layer.msg("采购单已提交,不可修改");
                return false;
            }
            //完善数据
            //获得当前表格数据,有数据并确认是够完整,可以根据数据表格回调函数获取所有数据判断
            if(drugMessageIds.length>0){
                var isX = true;//是否填写信息
                $.each(tableData,function(index,item) {
                    if(item.purchaseAmount==null||item.purchaseAmount==''||item.trading==null||item.trading==''){
                        isX = false;
                    }
                });
                layer.msg("请完善信息");
                if(!isX)
                   return false;
            }else {//无数据
                layer.msg("请添加采购药品");
                return false;
            }
            layer.confirm('提交采购单后不允许修改采购药品,是否继续?', {
                btn: ['确定','取消'] //按钮
            }, function(){
                //修改提交时间
                var submitTime = dateToString(new Date());
                $.post("/purchase/update",{id:id,purchaseState:2,submitTime:submitTime},function(res) {
                    layer.msg(res.msg);
                    setTimeout(function() {
                        window.location.href = '/toPurchase';
                    },1000);
                });
            }, function(){

            });
            return false;
        });
        //打开展示
        var mainIns;
        var url;
        function openShow(data) {
            mainIns = layer.open({
                type:1,
                content:$("#showData"),
                area:['800px','580px'],
                title:"查看详情",
                success:function(layero,index) {
                    form.val("showDataForm",data);
                    //采购状态
                    $.get("/getDataDictionary?dateType=3",function(res) {
                        $("#layerPurchaseState").val(res.data[$("#layerPurchaseState").val()].dataName);
                    });
                    form.val("showDataDrugForm",data.drugMessage);
                    //质量层次
                    $.get("/getDataDictionary?dateType=7",function(res) {
                        $("#layerQuality").val(res.data[$("#layerQuality").val()].dataName);
                    });
                    //药品类别
                    $.get("/getDrugCategoryById?drugCategoryId="+$("#layerDrugCategory").val(),function(res) {
                        $("#layerDrugCategory").val(res.category);
                    });
                    //是否进口药
                    $("#layerIsImport").val($("#layerIsImport").val()==1?"是":"否");
                    //有无质检报告
                    $("#layerHaveReport").val($("#layerHaveReport").val()==1?"有":"无");
                    //药品状态
                    $("#layerTransaction").val($("#layerTransaction").val()==1?"正常":"不正常");
                    form.val("showDataProviderForm",data.provider);
                }
            })
        }

        //修改供货企业
        function changeProvider(data) {
            if(purchaseState!=1&&purchaseState!=4){
                layer.msg("采购单已提交，不可修改");
                return;
            }
            console.log(data);
            var areaid;

            //获得采购单-->获得医院-->获得区域
            $.ajax({
                url:"/hospital/getHospitalById?id="+hospitalId,
                async:false,
                success:function(res) {
                    areaid = res.areaid;
                }
            })
            var tbIns;
            mainIns = layer.open({
                type:1,
                content:$("#selectProvider"),
                area:['400px','300px'],
                title:"查看详情",
                success:function() {
                    //渲染表格
                    tbIns = table.render({
                         elem:"#selectProvider",
                         url:"/provider/getAllAvaProvider",
                         where:{drugMessageId:data.drugMessageId,areaid:areaid},
                         id:"provider",
                         cols:[
                             [
                                 {field:'id', title:'ID',  fixed: 'left', unresize: true,width:'80' ,sort: true,align:'center'}
                                 ,{type:'radio',fixed:'center'}
                                 ,{field:'providerName', title:'企业名称',align:'center',width:'150'}
                                 ,{fixed: 'right', title:'详情 ', toolbar: '#row',width:'100'}
                             ]
                         ]

                    })
                },
                btn:['选择','关闭'],
                yes:function(index,layero) {
                    //添加采购药品细节
                    var checkStatus = table.checkStatus('provider');
                    console.log(checkStatus)
                    var providerId = checkStatus.data[0].id;
                    $.post("/updateProviderId",{providerId:providerId,id:data.id},function(data) {
                        layer.msg(data.msg);
                    })
                },
                btn2:function(){
                    $("#selectProvider").next().remove();
                },
                cancel:function() {
                    $("#selectProvider").next().remove();
                }
            })
        }
        //供货企业查看详情
        function showProvider(data) {
            console.log(data)
            mainIns = layer.open({
                type:1,
                content:$("#showProvider"),
                area:['800px','630px'],
                title:"查看详情",
                success:function(layero,index) {
                    form.val("showProviderForm",data);
                }
            })
        }
        //删除purchase_drup_detail
        function openDelete() {
            var checkStatus = table.checkStatus('drugTableId');
            if(checkStatus.data.length==0){
                layer.msg("请勾选要删除的数据");
                return;
            }
            if(purchaseState!=1&&purchaseState!=4){
                layer.msg("采购单已提交，不可修改");
                return;
            }
            var purchaseDrupDetailIds = new Array();
            $.each(checkStatus.data,function(index,item) {
                purchaseDrupDetailIds.push(item.id);
            });
            layer.confirm('提交采购单后不允许修改采购药品，是否继续？', {
                btn: ['确定','取消'] //按钮
            }, function(){
                $.ajax({
                    url:"/deletePurchaseDrupDetail",
                    data:{purchaseDrupDetailIds:purchaseDrupDetailIds},
                    dataType:"json",
                    type:"post",
                    traditional:true,
                    success:function(data) {
                        layer.msg(data.msg);
                        tableIns.reload();
                    }
                })
            }, function(){
            });
        }
        //打开添加采购药品
        function openAdd() {
            //跳转到添加采购药品界面
            //已经提交则不能修改
            if(purchaseState!=1&&purchaseState!=4){
                layer.msg("采购单已提交，不可修改");
                return;
            }
            window.location.href = "/toPurchaseCatalog?id="+id+"&drugMessageIds="+drugMessageIds+"&hospitalId="+hospitalId;

        }
        //保存采购量
        function openSave() {
            var checkStatus = table.checkStatus('drugTableId');
            //采购单状态限制是否可以修改
            if(purchaseState!=1&&purchaseState!=4){
                layer.msg("采购单已提交，不可修改");
                return;
            }
            //必须勾选数据
            if(checkStatus.data.length==0){
                layer.msg("请先勾选数据");
                return;
            }

            var purchaseDrupDetail = new Array();
            var isAva = true;
            $.each(checkStatus.data,function(index,item) {
                //交易价和采购数量非空限制,中标价>=交易价
                if(item.trading==""||item.purchaseAmount==""||item.trading==null||item.purchaseAmount==null||item.winPrice<item.trading){
                    isAva = false;
                }
                var a = {
                    id:item.id,
                    purchaseAmount:item.purchaseAmount,
                    trading:item.trading,
                    purchasePrice:item.purchaseAmount*item.trading
                };
                purchaseDrupDetail.push(a);
            })
            if(isAva){
                $.post("/updatePurchaseDrupDetails",{purchaseDrupDetailStr:JSON.stringify(purchaseDrupDetail)},function(data) {
                    layer.msg(data.msg);
                    tableIns.reload();
                })
            }else {
                layer.msg("请检查您填写的数据");
            }
        }
        //加载下拉框
        function select(item,url,dataNum) {
            $.get(url,function(data) {
                var html = "<option value='0'>请选择</option>";
                $.each(data.data,function(index,item) {
                    if(item.dataNum===dataNum){
                        html += "<option selected value='"+item.dataNum+"'>"+item.dataName+"</option>"
                    }else {
                        html += "<option value='"+item.dataNum+"'>"+item.dataName+"</option>"
                    }
                })
                item.empty();
                item.append(html);
                // $("#purchaseState").html(html);
                form.render();
            })
        }
        function selectDrugCategory(item,url) {
            $.get(url,function(data) {
                var html = "<option value='0'>请选择药品类别</option>";
                $.each(data,function(index,item) {
                    html += "<option value='"+item.id+"'>"+item.category+"</option>"
                })
                item.empty();
                item.append(html);
                // $("#purchaseState").html(html);
                form.render();
            })
        }
        function selectProvider(item,url) {
            $.get(url,function(data) {
                var html = "<option value='0'>请选择供应商</option>";
                $.each(data,function(index,item) {
                    html += "<option value='"+item.id+"'>"+item.providerName+"</option>"
                })
                item.empty();
                item.append(html);
                // $("#purchaseState").html(html);
                form.render();
            })
        }
        //日期转字符串方法
        function dateToString(date) {
            return date.getFullYear()+"-"+
                    ("0"+(date.getMonth()+1)).slice(-2)+"-"+
                    ("0"+date.getDate()).slice(-2)+" "+
                    ("0"+date.getHours()).slice(-2)+":"+
                    ("0"+date.getMinutes()).slice(-2)+":"+
                    ("0"+date.getSeconds()).slice(-2)
        }
    })

</script>
</body>
</html>


